<!DOCTYPE HTML>
<html>
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<!--[if lt IE 9]>
	<script type="text/javascript" src="lib/html5shiv.js"></script>
	<script type="text/javascript" src="lib/respond.min.js"></script>
	<![endif]-->
	<link href="/admin/static/h-ui/css/H-ui.min.css" rel="stylesheet" type="text/css" />
	<link href="/admin/static/h-ui.admin/css/H-ui.login.css" rel="stylesheet" type="text/css" />
	<link href="/admin/static/h-ui.admin/css/style.css" rel="stylesheet" type="text/css" />
	<link href="/admin/lib/Hui-iconfont/1.0.8/iconfont.css" rel="stylesheet" type="text/css" />
	<!--[if IE 6]>
	<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
	<script>DD_belatedPNG.fix('*');</script>
	<![endif]-->
	<title>后台登录</title>
	<meta name="keywords" content="H-ui.admin v3.1,H-ui网站后台模版,后台模版下载,后台管理系统模版,HTML后台模版下载">
	<meta name="description" content="H-ui.admin v3.1，是一款由国人开发的轻量级扁平化网站后台模板，完全免费开源的网站后台管理系统模版，适合中小型CMS后台系统。">
	<script type="text/javascript" src="/admin/lib/jquery/1.9.1/jquery.min.js"></script>
	<script type="text/javascript" src="/demo/layer3.1.0/layer/layer.js"></script>
	<script type="text/javascript">
		var countdown=60;
		function settime(obj) {
			//发送验证码倒计时
			if (countdown == 0) { 
				obj.attr('disabled',false);
				obj.val("获取验证码");
				countdown = 60;
				return;
			} else { 
				obj.attr('disabled',true);
				obj.val("重新发送(" + countdown + ")");
				countdown--; 
			} 
			setTimeout(function() {settime(obj)},1000)
		}

	</script>
</head>
<body>
	<div class="loginWraper">
		<div id="loginform" class="loginBox">
			<form class="form form-horizontal" id="myForm" method="post">
				<div class="row cl">
					<label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60d;</i></label>
					<div class="formControls col-xs-8">
						<input name="name" type="text" placeholder="账户" class="input-text size-L" value="">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60e;</i></label>
					<div class="formControls col-xs-8">
						<input name="password" type="password" placeholder="密码" class="input-text size-L" value="">
					</div>
				</div>
				<div class="row cl">
					<div class="formControls col-xs-8 col-xs-offset-3">
						<input class="input-text size-L" type="text" placeholder="验证码" name="code" style="width:150px;">
						<img src="{:captcha_src()}" class="form-control code" style="width:25%;display:inline;height:40px;cursor: pointer;">
						<a id="kanbuq" href="javascript:;" onClick="javascript:code();">看不清，换一张</a> 
					</div>
				</div>
				<div class="row cl">
					<div class="formControls col-xs-8 col-xs-offset-3">
						<input type="button" class="btn btn-success radius size-L user-login" value="&nbsp;登&nbsp;&nbsp;&nbsp;&nbsp;录&nbsp;">
						<input type="button" class="btn btn-default radius size-L forget-paw" value="忘记密码？" style="float: right;margin-right: 40px;">
					</div>
				</div>
			</form>
		</div>
		<div id="forget_paw" class="loginBox" style="display: none;">
			<form class="form form-horizontal">
				<div class="row cl">
					<label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe6c7;</i></label>
					<div class="formControls col-xs-8">
						<input name="forget-tel" type="text" class="input-text size-L" placeholder="请输入手机号">
					</div>
				</div>
				<div class="row cl">
					<div class="formControls col-xs-8 col-xs-offset-3">
						<input class="input-text size-L" type="text" placeholder="验证码" name="tel-code" style="width:150px;">
						<input type="button" class="input-text forget-code" style="width:25%;display:inline;height:40px;cursor: pointer;" value="获取验证码">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe63f;</i></label>
					<div class="formControls col-xs-8">
						<input name="new-password" type="text" placeholder="新密码" class="input-text size-L">
					</div>
				</div>
				<div class="row cl">
					<div class="formControls col-xs-8 col-xs-offset-3">
						<input type="button" class="btn btn-success radius size-L update-paw" value="确定修改">
						<input type="button" class="btn btn-default radius size-L go-login" value="前往登录" style="float: right;margin-right: 40px;">
					</div>
				</div>
			</form>
		</div>
	</div>
	<script type="text/javascript">
		function code(){
			$('.code').attr('src',$('.code').attr('src')+'?'+Math.random(1,9999));
		}
		$(function(){
			$(".user-login").click(function(){
					//console.log($("#myForm").serialize());return false;
					$.post("{:url('login')}",$("#myForm").serialize(),function(res){
						console.log(res)
						if (res.state==200) {
							location.href="{:url('index/index')}";
						}else{
							layer.msg(res.msg,{icon:7,time:1500});
							code();
						}
					})
				})
			$(document).keyup(function(event){
				if(event.keyCode ==13){
					$(".user-login").click();
				}
			});
			$(".forget-paw").click(function(){
				$("#forget_paw").show();$("#loginform").hide();
			})
			$(".go-login").click(function(){
				$("#forget_paw").hide();$("#loginform").show();
			})

			$(".forget-code").click(function(){
				var tel=$("input[name=forget-tel]").val();
			    if (/^1[3|4|5|7|8]\d{9}$/.test(tel)){
			        $.post("{:url('get_code')}",{mobile:tel,type:2},function(res){
			        	console.log(res);
			        	if (res.state==200) {
			        		layer.msg(res.msg,{icon:1,time:1500},function(){
			        			settime($(".forget-code"));
			        		});
			        	}else{
			        		layer.msg(res.msg,{icon:7,time:1500});
			        	}
			        })
			    }else{
					layer.msg("手机号格式错误！",{icon:7,time:1500})
			    }
			})
			
			$(".update-paw").click(function(){
				var tel=$("input[name=forget-tel]").val();if (tel=='' || !/^1[3|4|5|7|8][0-9]\d{4,8}$/.test(tel)) {layer.msg('手机号格式错误！',{icon:7,time:1500});return false;}
					code=$("input[name=tel-code]").val();if (code=='') {layer.msg('验证码不能为空！',{icon:7,time:1500});return false;}
					paw=$("input[name=new-password]").val();if (paw=='') {layer.msg('密码不能为空！',{icon:7,time:1500});return false;}
				$.post("{:url('forget_paw')}",{mobile:tel,code:code,paw:paw},function(res){
			        //console.log(res);
			        if (res.state==200) {
			        	layer.msg(res.msg,{icon:1,time:1500});
			        }else{
			        	layer.msg(res.msg,{icon:7,time:1500});
			        }
			    })
			})
		})
	</script>
</body>
</html>